Repository navigation
fix(cli): declare --config-file for fpm export - #1414
Merged
Merged
Conversation
`fpm export` read `config-file` through the shared build settings helper, but its command-line prototype did not declare the option. M_CLI2 then stopped with exit status 0 before anything was exported, so `fpm export --manifest m.json` wrote nothing and reported success. Declare `--config-file` for `export` as the other build subcommands do, and check in ci/run_tests.sh that `fpm export --manifest` writes the file.
--manifest, --model and --dependencies defaulted to "filename", so cmd_export always exported all three. The files that were not asked for went to ./filename, and --model without a file name crashed. They now default to blank, and cmd_export writes only the files it is given a name for. ci/run_tests.sh checks that each option writes its file and that no ./filename is created.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1413.
Since v0.13.0,
fpm exportdoes nothing and exits 0:fpm export --manifest m.jsonwrites nom.json. A gfortran build prints nothing; a flang build printsFortran STOP.build_settings(added in 1dfc4ec) readssget('config-file'), but theexportprototype never declared--config-file. M_CLI2 then stops with a barestop(exit status 0) beforecmd_exportruns.--config-file " "forexport, asbuild,run,test,install,update,cleanandpublishalready do.exportthen reads it likebuilddoes:build_modelpasses it to the global settings.build_settingsreads are already declared throughcommon_argsandcompiler_args.dumpis read only whenspecified('dump'), which returns false for an undeclared key, soexportdoes not need it.Since
fpm exportwas added (v0.10.1),--manifest,--modeland--dependenciesdefaulted to the string"filename", socmd_exportalways saw all three as given:fpm export --manifest m.jsonalso resolved the dependencies, built the model and wrote both to./filename.fpm export --model, with no file name, crashed with a segmentation fault (gfortran 16).They now default to blank, and
cmd_exportwrites only the files it is given a name for. With none (fpm export, orfpm export --modelalone), it prints<INFO> *cmd_export* exiting: no manifest/model/dependencies keyword providedand exits 0, as that code was written to do.ci/run_tests.sh:fpm export -C hello_worldmust writemanifest.jsonfor--manifest, andmodel.jsonanddependencies.jsonfor--modeland--dependencies, without creatingfilename. The cli-test caseexport --manifest manifest.json --flag "-O2"did not catch either bug. The child process stopped before writing_test_cli, and the parent read the previous test's results instead.Verification
macOS arm64, gfortran 16.2 and flang 23 (Homebrew):
The new
ci/run_tests.shcheck fails without the fix:test -f hello_world/manifest.jsonfails with both compilers, becauseexportexits 0 without writing it;--config-filedeclared,test ! -e hello_world/filenamefails with gfortran 16.With the fix,
fpm testpasses with both compilers, andci/run_tests.sh <fpm>passes with gfortran 16.In a scratch package, with
--config-filedeclared, before and after the new defaults (gfortran 16; the fixed flang 23 build gives the same results):fpm export --manifest m.jsonm.json,./filenameandbuild/m.jsononlyfpm export --model mo.jsonmo.json,./filenameandbuild/mo.jsonandbuild/fpm export --model<INFO>message, exit 0fpm export./filenameandbuild/, exit 0<INFO>message, exit 0